#include "myself.h"
#include "ui_myself.h"

#include "registeruserdialog.h"


Myself::Myself(QWidget *parent) : QWidget(parent),
    ui(new Ui::Myself)
{
    ui->setupUi(this);

//    QLabel *label = new QLabel(this);
//    label->setText("myself");
    //    label->move(50, 50); // 设置标签的位置

    connect(FlowControler::Interface, &XInterface::updateUserFinished, this, [=](int ret)
    {
        if(ret  == NoError)
        {
            setUser(*FlowControler::Interface->m_currentUser);
        }
    });
}

void Myself::setUser(Core::User &user)
{
    m_user = user;
    ui->labName->setText(user.name);
    ui->labDate->setText(user.birthDate);
    ui->labGender->setText(user.gender);
    ui->textEdit->setText(user.bio);
}

void Myself::on_btnEdit_clicked()
{
    RegisterUserDialog dialog;
    dialog.setUser(m_user);
    dialog.exec();
}
